from langchain_community.document_loaders import  TextLoader
from langchain_community.embeddings import OpenAIEmbeddings
from langchain_community.vectorstores import Chroma

# 准备文档
loader = TextLoader(r"D:\uidq0884\Desktop\大模型学习\3i.txt")
documents = loader.load()
# 创建向量数据库并持久化存储
vectorstore = Chroma(embedding_function=OpenAIEmbeddings(), persist_directory="./Chroma.db")
vectorstore = Chroma.from_documents(documents=documents, embedding=OpenAIEmbeddings())
